More with Legacy SQL

Building on the Views from Legacy SQL example:

doing more with legacy SQL bipp

doing more with legacy SQL bipp

Select the columns:

doing more with legacy SQL columns

bipp generates the SQL:

SELECT t000.stock_code AS _0, t000.unit_price AS _1 FROM (
    (SELECT t000.invoice_num AS invoice_num,
        t000.stock_code AS stock_code,
        t000.unit_price AS unit_price
    FROM (
        SELECT t.invoice_num AS invoice_num, t.stock_code AS
               stock_code, t.unit_price AS unit_price, t.country AS
               country FROM `online_retail`.`stocks` AS s JOIN
              `online_retail`.`transactions` AS t ON s.code = 
               t.stock_code WHERE s.description like '%TAPE%'
    ) AS t000
    GROUP BY 1, 2, 3
    )
    UNION ALL
    (
        SELECT ("unknown") AS invoice_num, t000.stock_code AS 
               stock_code, t000.unit_price AS unit_price FROM (SELECT 
               t.stock_code AS stock_code, t.unit_price/2 AS 
               unit_price, t.country AS country FROM
               `online_retail`.`stocks` AS s JOIN
               `online_retail`.`transactions` AS t ON s.code = 
               t.stock_code WHERE > NOT s.description like
               '%SCISSOR%'
    ) AS t000
    GROUP BY 1, 2, 3
    )
) AS t000
GROUP BY 1, 2

Fetch the data:

doing more with legacy SQL results

IN THIS PAGE